using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Stream stream = File.Open(@"C:\Users\Serhat\Desktop\f.txt", FileMode.OpenOrCreate);
            StreamReader reader = new StreamReader(stream);
            StreamWriter writer = new StreamWriter(stream);
            for (int i = 0; i < 20; i++ )
                writer.WriteLine("{0}:0xFF:Serhat:Demircan:20", i+1);
            writer.Flush();
            reader.BaseStream.Seek(0, SeekOrigin.Begin);
            Console.WriteLine(stream.Length);
            removeLine(18, reader, writer);
           
            writer.Close();
            reader.Close();
            
            stream.Close();
            Console.ReadLine();

        }

        public static void removeLine(int no, StreamReader reader, StreamWriter writer)
        {
            int counter = 0;
            string line = "";
            long positon = 0;
            while(counter < no && !reader.EndOfStream)
            {
                line = reader.ReadLine();
                positon = positon + line.Length;
                Console.WriteLine("String {0} Length {1}", line, line.Length);
                counter++;
            }
            positon += counter;
          ;
            //Console.WriteLine("String {0}, Cursor {1}", line.Length, reader.BaseStream.Position);

            string[] parsedLine = line.Split(':');
            parsedLine[1] = "0x00";
            line = "";
            for (int i = 0; i < parsedLine.Length; i++)
            {
                line += parsedLine[i];
                if (i < parsedLine.Length - 1)
                    line += ':';
            }
           
            writer.BaseStream.Seek(positon - line.Length + (counter -2 ), SeekOrigin.Begin);

            parsedLine[1] = "True";
            writer.WriteLine( line);
        }
    }
}
